import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';
import { ApiProperty } from '@nestjs/swagger';

@Schema({
  timestamps: true, // 自动添加createdAt和updatedAt字段
  collection: 'category', // 集合名称
  versionKey: false, // 不返回版本字段
})
export class Category extends Document {
  @ApiProperty({ description: '分类名称' })
  @Prop({ required: true, type: String, unique: true })
  classifyname: string;

  @ApiProperty({ description: '分类是否展示在前台', default: true })
  @Prop({ required: true, type: Boolean, default: true })
  isShow: boolean;

  @ApiProperty({ description: '分类排序', default: 0 })
  @Prop({ required: true, type: Number, default: 0 })
  sort: number;
}

export const CategorySchema = SchemaFactory.createForClass(Category);
